﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;

namespace UIOC.CodeAnalysis.Extensions;

internal static class SymbolExtensions {

    public static IEnumerable<AttributeData> GetAttributes(this ISymbol symbol, INamedTypeSymbol attributeSymbol) {
        if (symbol != null) {
            foreach (var attr in symbol.GetAttributes().Where(attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeSymbol))) {
                yield return attr;
            }
        }
    }
}
